package com.yilin.platform.base_core.application;

import java.io.Serializable;

public class ReturnData<T> implements Serializable {
    private boolean success;
    private int code;
    private String msg;
    private String token;
    private boolean isEncrypt;
    private T data;
    private String encData;

    public static <T> ReturnData<T> from(Boolean success, String msg){
        ReturnData<T> returnData = new ReturnData<>();
        returnData.setMsg(msg);
        returnData.setSuccess(success);
        returnData.setData(null);
        return returnData;
    }

    public static <T> ReturnData<T> from(Boolean success, String msg,T data){
        ReturnData<T> returnData = new ReturnData<>();
        returnData.setMsg(msg);
        returnData.setSuccess(success);
        returnData.setData(data);
        return returnData;
    }

    public static <T> ReturnData<T> from(Boolean success,int code, String msg,T data){
        ReturnData<T> returnData = new ReturnData<>();
        returnData.setMsg(msg);
        returnData.setCode(code);
        returnData.setSuccess(success);
        returnData.setData(data);
        return returnData;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getEncData() {
        return encData;
    }

    public void setEncData(String encData) {
        this.encData = encData;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public boolean getIsEncrypt() {
        return isEncrypt;
    }

    public void setIsEncrypt(boolean isEncrypt) {
        this.isEncrypt = isEncrypt;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
